namespace S2.UI
Description
This is the main user interface namespace.
Methods
Constants
-
FOCUSABLE_ELEMENTS #
A list of tag names representing elements that are (typically) focusable. Used by
S2.UI.isFocusable
.
Class methods
-
addBehavior #
S2.UI.addBehavior(element, behaviorClass[, options]) -> undefined
-
element
(Element
|Array
) – One or more elements on which to apply the behavior. -
behaviorClass
(Class
|Array
) – One or more subclasses ofUI.Behavior
. (Not instances!)
Add a behavior.
-
-
addClassNames #
S2.UI.addClassNames(elements, classNames) -> [Element...]
-
elements
(Element
|Array
) – An element (or collection of elements). -
classNames
(String
|Array
) – A space-separated string (or array) of class names to add.
Adds the class names to each of the given elements.
-
-
disableTextSelection #
S2.UI.disableTextSelection(element) -> Element
Disables text selection within the element.
-
enableTextSelection #
S2.UI.enableTextSelection(element) -> Element
Enables text selection within the element.
-
findFocusables #
S2.UI.findFocusables(element) -> [Element...]
Given an element, returns all focusable descendants.
-
getBehavior #
S2.UI.getBehavior(element, behaviorClass) -> S2.UI.Behavior
-
getText #
S2.UI.getText(element) -> String
Returns the text content of an element.
-
isFocusable #
S2.UI.isFocusable(element) -> Boolean
- element (Element): An element.
Tests whether the element is focusable. Will return
true
if the element is one of the commonly focusable kinds (and is not disabled) -- or if the element has had atabIndex
attribute set.
- element (Element): An element.
Tests whether the element is focusable. Will return
-
isVisible #
S2.UI.isVisible(element) -> Boolean
Tests whether the element is visible. Does not test whether the element is within the viewport -- only whether it (or any of its ancestors) is hidden via CSS.
-
makeFocusable #
S2.UI.makeFocusable(elements, bool) -> undefined
-
elements
(Element
|Array
) – An element (or collection of elements). -
shouldBeFocusable
(Boolean
) – Whether the elements should be focusable.
Alters the focusability of the element(s).
-
-
makeVisible #
S2.UI.makeVisible(elements, shouldBeVisible) -> [Element...]
- elements (Element | Array): An element (or collection of elements).
- shouldBeVisible (Boolean): Whether the given element(s) should be visible.
-
modifierUsed #
S2.UI.modifierUsed(event) -> Boolean
Given an event, returns
true
if at least one modifier key was pressed during the event. Ctrl, Alt, and Command (on the Mac) are considered modifier keys.For the purposes of this function,
SHIFT
is not considered a modifier key, because of commons shortcuts likeSHIFT + TAB
. -
moveHighlight #
S2.UI.moveHighlight(delta) -> this
- delta (Number): Number of "slots" to move the highlight. Positive numbers go down; negative numbers go up.
-
removeBehavior #
S2.UI.removeBehavior(element, behaviorClass) -> undefined
-
element
(Element
|Array
) – One or more elements on which to remove the behavior. -
behaviorClass
(Class
|Array
) – One or more subclasses ofUI.Behavior
. (Not instances!)
Remove a behavior.
-
-
removeClassNames #
S2.UI.removeClassNames(elements, classNames) -> [Element...]
-
elements
(Element
|Array
) – An element (or collection of elements). -
classNames
(String
|Array
) – A space-separated string (or array) of class names to remove.
Removes the class names from each of the given elements.
-
-
selectChoice #
S2.UI.selectChoice([element]) -> this
- element (Element | Number): The choice to select — either its DOM node or its index. If omitted, will select the highlighted choice.